//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.chris.serve;

import com.alibaba.fastjson.JSON;
import com.chris.entity.content;
import com.chris.impl.contentImpl;
import com.chris.utils.DbConnection;
import com.chris.utils.JsonProcess;
import com.chris.utils.LogUtil;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet({"/searchJournalPaper"})
public class searchJournalPaper extends HttpServlet {
    private final contentImpl dao = new contentImpl();

    public searchJournalPaper() {
    }

    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        PrintWriter writer = resp.getWriter();

        try {
            String Sid = req.getParameter("journal_id");
            if (Sid == null) {
                writer.print(JsonProcess.respError("参数错误"));
            } else {
                int id = Integer.parseInt(Sid);
                List<content> byID = this.dao.getByID(id);
                writer.print(JSON.toJSONString(JsonProcess.respSuccess("成功", byID)));
            }

        } catch (Exception var7) {
            writer.print(JsonProcess.respError("参数错误"));
            LogUtil.log("参数错误",var7);
        }
        DbConnection.endServe();

    }

    public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.addHeader("Access-Control-Allow-Headers", "*");
    }
}
